package com.example.function.project.model.pojo;


import com.example.common.support.ApplicationContextProvider;
import com.example.function.project.model.one.ProjectFile;
import com.example.function.project.service.IProjectFileService;
import com.example.function.sys.service.ISysUserService;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Description: <ProjectFilePojo vo>. <br>
 * <p>
 * generate time:2021-7-29 16:28:21
 *
 * @author hanqf
 * @version V1.0
 */
@Data
public class ProjectFilePojo implements Serializable {
    private static final long serialVersionUID = 1L;

    /*
     * 项目文件id
     */
    private java.lang.Long id;


    /*
     * 项目id
     */
    private java.lang.Long projectId;


    /*
     * 项目文件名称
     */
    private java.lang.String fileName;

    /*
     * 项目实际存储文件名称
     */
    private java.lang.String fileSaveName;


    /*
     * 文件大小（byte）
     */
    private java.lang.Long fileSize;


    /*
     * 上传时间
     */
    private java.util.Date fileUploadtime;


    /*
     * 操作人id
     */
    private java.lang.Long userId;

    /*
     * 操作人姓名
     */
    private java.lang.String userName;



    /**
     * 实体对象复制到数据对象
     */
    public static ProjectFilePojo wrapper(ProjectFile projectFile) {
        ProjectFilePojo projectFilePojo = new ProjectFilePojo();
        BeanUtils.copyProperties(projectFile, projectFilePojo);
        final IProjectFileService projectFileService = (IProjectFileService) ApplicationContextProvider.getBean("projectFileService");

        final ISysUserService sysUserService = (ISysUserService) ApplicationContextProvider.getBean("sysUserService");
        final String userName = sysUserService.findById(projectFile.getUserId()).getUserName();
        projectFilePojo.setUserName(userName);
        return projectFilePojo;
    }

    public static List<ProjectFilePojo> wrapper(List<ProjectFile> projectFiles) {
        List<ProjectFilePojo> list = new ArrayList<>();
        for (ProjectFile projectFile : projectFiles) {
            list.add(ProjectFilePojo.wrapper(projectFile));
        }
        return list;
    }

}



